/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Classes;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
/**
 *
 * @author userinsta
 */
public class RenseignementMarqueRestaurant {
    
    private JFrame _frame;
    private JPanel _demandeMR;
    private JButton _submit;
    private JTextField txtNomM;
    private JTextField txtAdresseM;
    private JTextField txtCodePostalM;
    private JTextField txtVilleM;
    private JTextField txtNbSalarieM;
    private JTextField txtNomR;
    private JTextField txtAdresseR;
    private JTextField txtCodePostalR;
    private JTextField txtVilleR;
    private JTextField txtNbSalarieR;
    public RenseignementMarqueRestaurant(){
        this.init();
    }    
    public void init() {
        this._frame = new JFrame("Informations sur votre Marque/Restaurant");
        this.initFrame();
    }
    
    public void initFrame(){
        this._submit = new JButton("Valider");
        _submit.addActionListener(new ActionSubmit());
        this._frame.setSize(900, 500);
        this._frame.add(creePanelNord(),"North");
        this._frame.add(creePanelCentre(),"Center");
        this._frame.add(creerPanelSud(),"South");
        this._frame.setVisible(true);
        this._frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
    public JPanel creePanelNord(){
        JPanel panelLogo = new JPanel();
        panelLogo.setLayout(new BorderLayout());
        JLabel image = new JLabel( new ImageIcon("C:\\Users\\userinsta\\Documents\\NetBeansProjects\\trunk\\ProjetLucasDany\\src\\Logo.png"));
        JLabel lblTitre = new JLabel("Renseignez votre Marque/Restaurant",SwingConstants.CENTER);
        Font font = new Font("Arial",Font.BOLD,28);
        lblTitre.setFont(font);
        panelLogo.add(image,BorderLayout.LINE_START);
        panelLogo.add(lblTitre);
        panelLogo.setBackground(Color.white);
        return panelLogo;
    }
    public JPanel creePanelCentre(){
        _demandeMR = new JPanel();
        _demandeMR.setLayout(new BorderLayout());
        JButton bMarque = new JButton("   MARQUE   ");
        JButton bRestaurant= new JButton("RESTAURANT");
        JLabel choix = new JLabel("<---- Vous voulez créer une marque ou un restaurant ? ---->",SwingConstants.CENTER);
        Font font1 = new Font("Arial",Font.PLAIN,20);
        choix.setFont(font1);
        _demandeMR.add(bMarque,BorderLayout.LINE_START);
        _demandeMR.add(choix);
        _demandeMR.add(bRestaurant,BorderLayout.LINE_END);
        bMarque.addActionListener(new ActionMarque());
        bRestaurant.addActionListener(new ActionRestaurant());
        _demandeMR.setBackground(Color.white);
        return _demandeMR;
    }
    
    
    public JPanel Restaurant(){
    
    // Les zones de Textes
    txtNomR = new JTextField();
    txtAdresseR = new JTextField();
    txtCodePostalR = new JTextField();
    txtVilleR = new JTextField();
    txtNbSalarieR = new JTextField();
    // Création des labels 
    JLabel lblNom = new JLabel("Nom du restaurant :", JLabel.RIGHT);
    lblNom.setLabelFor(txtNomR);       // Définir le composant qui es labelé
    JLabel lblAdresse = new JLabel("Adresse :", JLabel.RIGHT);
    lblAdresse.setLabelFor(txtAdresseR);
    JLabel lblVille = new JLabel("Ville :", JLabel.RIGHT);
    lblVille.setLabelFor(txtVilleR);
    JLabel lblCodePostal = new JLabel("Code Postal :", JLabel.RIGHT);
    lblCodePostal.setLabelFor(txtCodePostalR);
    JLabel lblNbSalarie = new JLabel("Nombre de Salarié :", JLabel.RIGHT);
    lblNbSalarie.setLabelFor(txtNbSalarieR);
    JPanel panelRestaurant = new JPanel();
    panelRestaurant.setLayout(new GridLayout(5, 2, 7, 7));
    panelRestaurant.add(lblNom,BorderLayout.LINE_START);
    panelRestaurant.add(txtNomR,BorderLayout.LINE_START);
    panelRestaurant.add(lblAdresse,BorderLayout.LINE_START);
    panelRestaurant.add(txtAdresseR,BorderLayout.LINE_START);
    panelRestaurant.add(lblVille,BorderLayout.LINE_START);
    panelRestaurant.add(txtVilleR,BorderLayout.LINE_START);
    panelRestaurant.add(lblCodePostal,BorderLayout.LINE_START);
    panelRestaurant.add(txtCodePostalR,BorderLayout.LINE_START);
    panelRestaurant.add(lblNbSalarie,BorderLayout.LINE_START);
    panelRestaurant.add(txtNbSalarieR,BorderLayout.LINE_START);
    panelRestaurant.setBackground(Color.white);
    panelRestaurant.add(_submit);
    return panelRestaurant;
    }
    
    public JPanel creerPanelSud(){
        JPanel panel = new JPanel();
        panel.setBackground(Color.white);
        JLabel label = new JLabel("Dany Patient - Lucas Lemaire © 2014");
        panel.add(label);
        return panel;
    }   
    public JPanel MarqueRestaurant(){
        JPanel panelMarqueRestaurant = new JPanel();
        JPanel panelMarque = new JPanel();
        panelMarque.setLayout(new GridLayout(5, 2, 7, 7));
        // Les zones de Textes
        txtNomM = new JTextField();
        txtAdresseM = new JTextField();
        txtCodePostalM = new JTextField();
        txtVilleM = new JTextField();
        txtNbSalarieM = new JTextField();

        // Les zones de Textes
        txtNomR = new JTextField();
        txtAdresseR = new JTextField();
        txtCodePostalR = new JTextField();
        txtVilleR = new JTextField();
        txtNbSalarieR = new JTextField();

        // Création des labels Marque
        JLabel lblNomM = new JLabel("Nom de la marque :");
        lblNomM.setLabelFor(txtNomM);       // Définir le composant qui est labelé
        JLabel lblAdresseM = new JLabel("Adresse :");
        lblAdresseM.setLabelFor(txtAdresseM);
        JLabel lblVilleM = new JLabel("Ville :");
        lblVilleM.setLabelFor(txtVilleM);
        JLabel lblCodePostalM = new JLabel("Code Postal :");
        lblCodePostalM.setLabelFor(txtCodePostalM);
        JLabel lblNbSalarieM = new JLabel("Nombre de Salarié :");
        lblNbSalarieM.setLabelFor(txtNbSalarieM);
        panelMarque.add(lblNomM);
        panelMarque.add(txtNomM);
        panelMarque.add(lblAdresseM);
        panelMarque.add(txtAdresseM);
        panelMarque.add(lblVilleM);
        panelMarque.add(txtVilleM);
        panelMarque.add(lblCodePostalM);
        panelMarque.add(txtCodePostalM);
        panelMarque.add(lblNbSalarieM);
        panelMarque.add(txtNbSalarieM);
        
        JPanel panelRestaurant = new JPanel();
        panelRestaurant.setLayout(new GridLayout(5, 2, 7, 7));
        // Création des labels Restaurant
        JLabel lblNomR = new JLabel("Nom du restaurant :");
        lblNomR.setLabelFor(txtNomM);       // Définir le composant qui es labelé
        JLabel lblAdresseR = new JLabel("Adresse :");
        lblAdresseR.setLabelFor(txtAdresseM);
        JLabel lblVilleR = new JLabel("Ville :");
        lblVilleR.setLabelFor(txtVilleM);
        JLabel lblCodePostalR = new JLabel("Code Postal :");
        lblCodePostalR.setLabelFor(txtCodePostalM);
        JLabel lblNbSalarieR = new JLabel("Nombre de Salarié :");
        lblNbSalarieR.setLabelFor(txtNbSalarieM);
        panelRestaurant.add(lblNomR);
        panelRestaurant.add(txtNomR);
        panelRestaurant.add(lblAdresseR);
        panelRestaurant.add(txtAdresseR);
        panelRestaurant.add(lblVilleR);
        panelRestaurant.add(txtVilleR);
        panelRestaurant.add(lblCodePostalR);
        panelRestaurant.add(txtCodePostalR);
        panelRestaurant.add(lblNbSalarieR);
        panelRestaurant.add(txtNbSalarieR);    
        panelMarque.setBackground(Color.white);
        panelRestaurant.setBackground(Color.white);
        panelMarqueRestaurant.setBackground(Color.white);
        panelMarqueRestaurant.add(panelMarque);
        panelMarqueRestaurant.add(panelRestaurant);
        panelMarqueRestaurant.add(_submit);
        return panelMarqueRestaurant;
    }
    public class ActionMarque implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent ae) {
           _demandeMR.setVisible(false);
           _frame.add(MarqueRestaurant(),"Center");
      }  
    }
    public class ActionRestaurant implements ActionListener{

       @Override
       public void actionPerformed(ActionEvent ae) {
           _demandeMR.setVisible(false);
           _frame.add(Restaurant(),"Center");      
       }
        
      }
    public class ActionSubmit implements ActionListener{

       @Override
       public void actionPerformed(ActionEvent ae) {
           ArrayList<Restaurant> restaurants = new ArrayList();
           restaurants.add(new Restaurant(new Adresse(txtNomR.getText(), txtAdresseR.getText(), txtVilleR.getText(), Integer.parseInt(txtCodePostalR.getText())), txtNomR.getText(), null, null, null, null, null, new ArrayList<Salarie>()));
           Marque marque = Marque.getInstance(txtNomM.getText(), restaurants, null, null);
 _frame.dispose();
           new GestionERP();
       //    _frame.dispose();
       }
        
      }
    }
    
    
